﻿using System;
using Newtonsoft.Json;

namespace Business.Entities 
{
    public abstract class NilzBusinessBase<T>
    {
        /// <summary>
        /// Clones the entire object graph using Json serializing
        /// </summary>
        /// <returns></returns>
        public T Clone()
        {
            var settings = new JsonSerializerSettings();
            settings.DefaultValueHandling = DefaultValueHandling.Ignore;
            var json = JsonConvert.SerializeObject(this, Formatting.None, settings);
            return JsonConvert.DeserializeObject<T>(json, settings);
        }
    }
}
